The Drawer Controller (attached to Gameboard) exposes all the system drawer features available to creators. This controller primarily lets creators show/hide the system drawers to allow for more real estate in the game.

Video Walkthrough:

Step-by-Step

The Gameboard prefab is always available in your game as long as the SDK has been integrated. In order to access it from our custom Mono Behavior we just need to find it by its tag.

    GameObject gameboardObject = GameObject.FindWithTag("Gameboard");

With access to our Gameboard object we can then move on to obtain a reference to the Drawer Controller. This controller handle the visibility of the player drawers to allow games more space when the drawers don't need to be present.

We will first need to define a reference to the controller to make it available throughout our script:

     DrawerController drawerController;

We can no proceed to request the controller from the Gameboard object.

     GameObject gameboardObject = GameObject.FindWithTag("Gameboard");
     drawerController = gameboardObject.GetComponent<DrawerController>();

We can now proceed to listen for orientation events. In our case we'll have a function called OrientationChange handle these events.

    drawerController.OnOrientationChange += OrientationChange;

Now that we are able to receive the orientation events, which would be triggered any time a player clicks the ‘Rotate to Me' from within their player drawer. This event will return the user id of the player that requested the rotation, and the rotation their drawer is on the gameboard in degrees.

    void OnOrientationChange(OrientationEventArgs eventArgs)
    {
        // Handle orientation change request
        // eventArgs.ownerId - userID of the request
        // eventArgs.orientation - rotation in degree
    }

The Drawer Controller allow the making of requests to the system drawers. The following requests are supported:

Hide the drawers:

    // Hide drawers
    drawerController.HideDrawers();

Show the drawers:

    drawerController.ShowDrawers();

The Drawer Controller allows you to show an icon indicating to double tap to reveal the drawers. The following methods can be used to show or hide those indicators:

Show the indicator, for a certain duration:

drawerController.StartDrawerIndicator(int durationMillis)

Stop the indicator from showing:

drawerController.StopDrawerIndicator()

This section include the entire code in one single, easy to copy section.

    DrawerController drawerController;

    // Start is called before the first frame update
    void Start()
    {
        GameObject gameboardObject = GameObject.FindWithTag("Gameboard");
        drawerController = gameboardObject.GetComponent<DrawerController>();
        drawerController.OnOrientationChange += OrientationChange;
    }

    void OnOrientationChange(OrientationEventArgs eventArgs)
    {
        // Handle orientation change request
        // eventArgs.ownerId - userID of the request
        // eventArgs.orientation - rotation in degree
    }

    void OnDestroy()
    {
        drawerController.OnOrientationChange -= OnOrientationChange;
    }